import {GET_TICKET_LST} from './constants';

const initState = {
  ticketList: [],
  footText: '',
  hasMore: true,
  isLoading: false,
  isRefresh: false
}

const reducer = (state = initState, action) => {
  switch (action.type) {
    case GET_TICKET_LST:
      let res;
      if (action.payload.isRefresh) {
        res = Object.assign({}, state, action.payload);        
      } else {
        res = Object.assign({}, state, action.payload, {ticketList: state.ticketList.concat(action.payload.ticketList)});
      }
      return res
    default:
      return state;
  }
};

export default reducer;
